package main

import (
	"database/sql"
	"fmt"
	"github.com/pkg/errors"
)

type Dao struct{}

func (dao Dao) do() error {
	fmt.Println("dao done")
	return sql.ErrNoRows
}

type Logic struct {
	dao Dao
}

func NewLogic(dao Dao) Logic {
	return Logic{dao: dao}
}
func (l Logic) DoXX() error {
	if err := l.dao.do(); err != nil {
		return errors.Wrap(err, "logic err")
	}
	return nil
}

func main() {

	d := Dao{}
	l := NewLogic(d)
	if err := l.DoXX(); err != nil {
		fmt.Printf("%+v\n", err)
	}
}
